package algorithm.leetcode.simple;

/**
 * @author jack.wu
 * @version 1.0
 * @date 2020/9/28
 */
public class Question36 {
    public static void main(String[] args) {

    }

    public int maxSubArray(int[] nums) {
        int sum = 0;
        int result = nums[0];

        for (int num : nums) {
            if (sum > 0) {
                sum += num;
            }else {
                sum = num;
            }
            result = Math.max(result, sum);
        }
        return result;
    }
}
